define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/walletrecord/index',
                    del_url: 'user/walletrecord/del',
                    table: 'wallet_record',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {field: 'id', title: __('Id'),operate:false},
                        {field: 'record_sn', title: '交易流水号'},
                        {field: 'user.username', title: '账号'},
                        {
                            field: 'type',
                            title: '交易类型',
                            searchList:{
                                "1":'微信充值',
                                "2":'提现',
                                "3":'下注',
                                "4":'中奖',
                                "5":'赠送',
                                "8":'支付宝充值',
                                "7":'银行转账',
                                "9":'下分',
                                "12":'撤单',
                                "13":'转入周期宝',
                                "14":"周期宝收益",
                                "15":"返还周期宝本金",
                                "16":"转入月期宝",
                                "17":"月期宝收益",
                                "18":"返还月期宝本金",
                            }
                        },
                        {field: 'remark', title: '交易备注'},
                        {field: 'money', title: '交易金额', operate:'BETWEEN'},
                        {field: 'log.money', title: '余额', operate:false},

                        {field: 'pay_status', title: __('Pay_status'), searchList: {"0":__('Pay_status 0'),"1":__('Pay_status 1'),"-1":__('Pay_status -1')}, formatter: Table.api.formatter.status},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operation_name', title: '操作人', operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});